package com.keqing.tomato.state;

import static android.widget.Toast.LENGTH_SHORT;
import static com.keqing.tomato.service.TimerService.minToMinSec;

import android.widget.Toast;

public class BeginRestState extends State {

    @Override
    public void initPage() {
        String text = null;
        Boolean deadTimeVisible = null;
        String deadTime = null;
        if (fragment.timeModeBtn.isChecked()) {//倒计时
            text = minToMinSec(fragment.mySetting.getRestTime());
            deadTimeVisible = false;
        } else {
            text = minToMinSec(0);
            deadTimeVisible = true;
            deadTime = minToMinSec(fragment.mySetting.getRestTime());
        }
        setPageContent(text, deadTimeVisible, deadTime, fragment.beginRestBtn);
    }

    @Override
    public void clickBeginFocus() {
        //no this event
    }

    @Override
    public void clickBeginRest() {
        fragment.changeState(new RestingState());
        setPageContent(null, null, null, fragment.restingBtn);
        fragment.timerService.startTimer(fragment.mySetting.getRestTime(), fragment.timeModeBtn.isChecked());
    }

    @Override
    public void doTimerFinish() {
        //no this event
    }

    @Override
    public void clickReset() {
        State state = new BeginFocusState();
        fragment.changeState(state);
        state.initPage();
        Toast.makeText(fragment.activity, "重置成功", LENGTH_SHORT).show();

    }

    @Override
    public void clickTimeMode() {
        Toast.makeText(fragment.activity, "计时模式设置成功", LENGTH_SHORT).show();
        initPage();
    }

}
